﻿//Copyrigh (C) 2021 上海东欣软件工程有限公司 版权所有。
//<author>邢耀光</author>
//<data>2021.1.31</data>

using Core;
using System.Collections.Generic;
using System.Data;

namespace Dal
{
    /// <summary>
    /// 用户操作类接口
    /// </summary>
    public interface IUserDao
    {
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>影响行数，1成功，0失败</returns>
        int InsertUser(User user, string connString);

        /// <summary>
        /// 修改用户
        /// </summary>
        /// <param name="user">用户信息</param
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>影响行数，1成功，0失败</returns>
        int UpdateUser(User user, string connString);

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="id">用户id</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>影响行数，1成功，0失败</returns>
        int DeleteUser(long id, string connString);

        /// <summary>
        /// 删除用户根据部门ID
        /// </summary>
        /// <param name="departmentID">部门id</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>影响行数，1成功，0失败</returns>
        int DeleteUserByDepartment(long departmentID, string connString);

        /// <summary>
        /// 分页模糊查询用户
        /// </summary>
        /// <param name="args">用户查询参数信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="page_size">页数显示大小</param>
        /// <param name="page_index">页数索引</param>
        /// <param name="totalRows">总行数</param>
        /// <returns>查询结果集</returns>
        DataTable QueryUserPages(User args, string connString, int page_size, int page_index, out int totalRows);

        /// <summary>
        /// 分页精确查询用户
        /// </summary>
        /// <param name="args">用户查询参数信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="page_size">页数显示大小</param>
        /// <param name="page_index">页数索引</param>
        /// <param name="totalRows">总行数</param>
        /// <returns>查询结果集</returns>
        DataTable ExactQueryUserPages(User args, string connString, int page_size, int page_index,out int totalRows);

        /// <summary>
        /// 模糊查询用户
        /// </summary>
        /// <param name="args">用户查询参数信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>查询结果集</returns>
        List<User> QueryUser(User args, string connString);


        /// <summary>
        /// 精确查询用户
        /// </summary>
        /// <param name="args">用户查询参数信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>查询结果集</returns>
        List<User>  ExactQueryUser(User args, string connString);

        /// <summary>
        /// 模糊查询用户
        /// </summary>
        /// <param name="args">用户查询参数信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>查询结果集</returns>
        DataTable QueryUserDT(User args, string connString);


        /// <summary>
        /// 精确查询用户
        /// </summary>
        /// <param name="args">用户查询参数信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>查询结果集</returns>
        DataTable ExactQueryUserDT(User args, string connString);

        /// <summary>
        /// 根据用户名称和所属部门id判断是否已经存在当前用户
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="userName">用户名称</param>
        /// <param name="departmentID">部门名称</param>
        /// <returns>是否存在</returns>
        bool ExistUser(string connString, string userName, int departmentID);

        /// <summary>
        /// 使用SqlBulkCopy批量插入
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="usrsDT">批量插入数据</param>
        /// <returns></returns>
        bool ImportUser(string connString, DataTable usrsDT);
    }
}
